package com.cb.admin.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.cb.util.PropertiesUtil;

/**
 * RestFull的请求方式
 * @author Administrator
 *
 */
@RestController
public class HelloRestController {
	
	@Autowired
	private PropertiesUtil propertiesUtil;
	
	/**
	 * @Controller：修饰class，用来创建处理http请求的对象
	   @RestController：Spring4之后加入的注解，原来在@Controller中返回json需要
		@ResponseBody来配合，如果直接用@RestController替代@Controller就不需要再配置
		@ResponseBody，默认返回json格式。
	   @RequestMapping：配置url映射
	 * @return
	 */
    @RequestMapping("/hello1")
    @ResponseBody
    public String hello1() {
        return "Hello World";
    }

    @RequestMapping("/cb")
    public String cb() {
        return propertiesUtil.getName()+"Hello World"+propertiesUtil.getTitle();
    }

}